<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/MasterPage.Master"
    Inherits="System.Web.Mvc.ViewPage<IEnumerable<Animoso.Domain.Event>>" %>
<%@ Import Namespace="Animoso.Domain" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Index
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Agenda beheren</h2>
    <fieldset>
        <p>
            <label>
                Agenda Titel:</label><br />
            <%= Html.TextBox("agendaTitle", ViewData["agendaTitle"], new Dictionary<string, object>{{"Id", "agendaTitle"}}) %>
            <div id="titleMessage" style="display: none;">Agenda titel gewijzigd</div>
        </p>
        <p>
            <label>
                Agenda beschrijving:</label><br />
            <textarea id="agendaDescription" cols="40" rows="20"><%=ViewData["agendaDescription"]%></textarea>
            <div id="descriptionMessage" style="display: none;">Beschrijving gewijzigd</div>
        </p>
        <p>
            <input id="submitLabel" type="submit" value="Wijzig" />
        </p>
    </fieldset>
    <%=Html.ActionLink("Nieuw Evenement", "Create", "Event") %>
    <br />
    <br />    
   <p><%=ViewData["agendaDescription"] %></p><br />
    <%
        for (var datum = DateTime.Now; datum < DateTime.Now.AddYears(1); datum = datum.AddMonths(1))
        {
            %><span class="EventMaand"><%=Html.Encode(datum.ToString("MMMM"))%></span>
            <p>
            <%
            IEnumerable<Event> currentEvents = Model.Where(x => x.DateTime.Month.Equals(datum.Month))
                .Where(x => x.DateTime.Year == datum.Year);
            foreach (var eventItem in currentEvents.OrderBy(x => x.DateTime))
            {%>
                <a style="float: right;" href="#"><img src="Content/Images/File-Delete-icon-large.png" /></a>
                <a style="float: right;" href="#"><img src="Content/Images/Edit-Document-icon-large.png" /></a>
                <span class="EventDatumGroot"><%=Html.Encode(eventItem.DateTime.ToLongDateString()) %></span><br />
                <span class="EventItemGroot"><%=Html.Encode(eventItem.Name)%></span><br />
                <span class="EventBeschrijving"><%=Html.Encode(eventItem.Description) %></span><br /><br />
            <%}%>
            </p>
        <%}%>

    <script type="text/javascript">
        $("#submitLabel").click(function() {
            var agendaTitle = $("#agendaTitle").val();
            var agendaDescription = $("#agendaDescription").val();

            $.ajax({ url: "Label/SetLabel", data: "name=agendaTitle&value=" + agendaTitle, context: document.body,
                success: function(val) {
                $("#titleMessage").fadeIn("slow");
                }
            });

            $.ajax({ url: "Label/SetLabel", data: "name=agendaDescription&value=" + agendaDescription, context: document.body,
                success: function(val) {
                $("#descriptionMessage").fadeIn("slow");
                }
            });
        });
    </script>

</asp:Content>
